Skip to contentSkip to conversation

Change in openvpn[master]: tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Nov 20, 2025 – Nov 22, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1763650333000.Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email

to review the following change.

Change subject: tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age
......................................................................

tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

Coverity complained about "overflow_before_widen" because there is a theoretical overflow that can happen even though the target value is wide enough. For useful values of max_days this is irrelevant but Coverity is not wrong, so change the code accordingly.

Change-Id Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7

---
M src/openvpn/tls_crypt.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1385/1

src/openvpn/tls_crypt.c +1 -1
index 318c939..9026cff 100644
@@ -539,7 +539,7 @@
     int64_t timestamp;
     memcpy(&timestamp, metadata + 1, sizeof(int64_t));
     timestamp = (int64_t)ntohll((uint64_t)timestamp);
-    int64_t max_age_in_seconds = max_days * 24 * 60 * 60;
+    int64_t max_age_in_seconds = (int64_t)max_days * 24 * 60 * 60;
     if (now - timestamp > max_age_in_seconds)
     {
         msg(M_WARN, "ERROR: Client key is too old.");

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7
Gerrit-Change-Number: 1385
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email )

Change subject: tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7
Gerrit-Change-Number: 1385
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 22 Nov 2025 16:25:38 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

Coverity complained about "overflow_before_widen" because there is a theoretical overflow that can happen even though the target value is wide enough. For useful values of max_days this is irrelevant but Coverity is not wrong, so change the code accordingly.

Change-Id Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1385
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1385
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/tls_crypt.c +1 -1
index 318c939..9026cff 100644
@@ -539,7 +539,7 @@
     int64_t timestamp;
     memcpy(&timestamp, metadata + 1, sizeof(int64_t));
     timestamp = (int64_t)ntohll((uint64_t)timestamp);
-    int64_t max_age_in_seconds = max_days * 24 * 60 * 60;
+    int64_t max_age_in_seconds = (int64_t)max_days * 24 * 60 * 60;
     if (now - timestamp > max_age_in_seconds)
     {
         msg(M_WARN, "ERROR: Client key is too old.");
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

What it says... :-) - stared-at, not tested in any meaningful way.

Your patch has been applied to the master branch.

commit 2969837ad347a227e1d33b1c71390d85f16aa2cd

Author: Frank Lichtenheld
Date:   Sat Nov 22 17:25:47 2025 +0100
     tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1385
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34585.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age
......................................................................

tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

Coverity complained about "overflow_before_widen" because there is a theoretical overflow that can happen even though the target value is wide enough. For useful values of max_days this is irrelevant but Coverity is not wrong, so change the code accordingly.

Change-Id Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1385
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34585.html

---
M src/openvpn/tls_crypt.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1385/2

src/openvpn/tls_crypt.c +1 -1
index 318c939..9026cff 100644
@@ -539,7 +539,7 @@
     int64_t timestamp;
     memcpy(&timestamp, metadata + 1, sizeof(int64_t));
     timestamp = (int64_t)ntohll((uint64_t)timestamp);
-    int64_t max_age_in_seconds = max_days * 24 * 60 * 60;
+    int64_t max_age_in_seconds = (int64_t)max_days * 24 * 60 * 60;
     if (now - timestamp > max_age_in_seconds)
     {
         msg(M_WARN, "ERROR: Client key is too old.");

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7
Gerrit-Change-Number: 1385
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email )

Change subject: tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age
......................................................................

tls_crypt: Fix Coverity complaint in tls_crypt_v2_check_client_key_age

Coverity complained about "overflow_before_widen" because there is a theoretical overflow that can happen even though the target value is wide enough. For useful values of max_days this is irrelevant but Coverity is not wrong, so change the code accordingly.

Change-Id Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1385
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34585.html

---
M src/openvpn/tls_crypt.c

1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/tls_crypt.c +1 -1
index 318c939..9026cff 100644
@@ -539,7 +539,7 @@
     int64_t timestamp;
     memcpy(&timestamp, metadata + 1, sizeof(int64_t));
     timestamp = (int64_t)ntohll((uint64_t)timestamp);
-    int64_t max_age_in_seconds = max_days * 24 * 60 * 60;
+    int64_t max_age_in_seconds = (int64_t)max_days * 24 * 60 * 60;
     if (now - timestamp > max_age_in_seconds)
     {
         msg(M_WARN, "ERROR: Client key is too old.");

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1385?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie7308d549182a95b86cd113e4a8cc65ff45ba3d7
Gerrit-Change-Number: 1385
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>